<template>
  <div>
    <!-- <div>{{ $store.state.name }}</div> -->
    <!-- <div>{{ name }}</div>
    <button @click="setName('小明')">改 name</button>
    <button @click="asyncSetName">延迟设置name</button>
    <div>
      {{ studentAddr }}
    </div>
    <div>{{ $store.state.testModule.name }}</div>
    <button @click="$store.commit('testModule/setNameTest')">改模块name</button> -->
    全局数据{{ name }}
    <div>
      模块数据 {{ nameTest }}
    </div>
  </div>
</template>

<script>
// 创建基于 user 模块的辅助函数
import { createNamespacedHelpers } from 'vuex'
const { mapState: mapStateTest } = createNamespacedHelpers('testModule')
// 辅助函数
import {
  mapState as mapStateGlobal,
  mapMutations,
  mapActions,
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapStateGlobal(['name']),
    ...mapGetters(['studentAddr']),
    ...mapStateTest({
      nameTest: 'name'
    })
  },
  methods: {
    ...mapMutations(['setName']),
    ...mapActions(['asyncSetName'])
  }
}
</script>

<style>

</style>
